<?php
/**
 * Created by PhpStorm.
 * User: kajun
 * Date: 2017/4/6
 * Time: 20:38
 */
namespace Home\Controller;

class VideoController extends HomeController
{
    public function video($id = null)
    {
        if ($id == null) {
            $this->error('视频id错误');
        } else {
            //        微博
            $weibo = M('Url')->find();
            $this->assign('weibo', $weibo);
            $video = M('Video')->where(array('id' => $id))->find();
            $advs = M('Advertisement')->where(array('show' => '1'))->order('create_time desc')->select();
            $link = D('Link')->order('create_time desc')->select();
            $this->assign('link', $link);
            $this->assign('advs', $advs);
            $this->assign('video', $video);
            $this->display();
        }
    }

    public function detail(){
        //        微博
        $weibo = M('Url')->find();
        $this->assign('weibo', $weibo);
        $video = M('Video')->where(array('show'=>'1'))->select();
        $size = sizeof($video)/3;
        $this->assign('size',ceil($size));
        $advs = M('Advertisement')->where(array('show' => '1'))->order('create_time desc')->select();
        $link = D('Link')->order('create_time desc')->select();
        $this->assign('link', $link);
        $this->assign('advs', $advs);
        $this->assign('video',$video);
        $this->display();
    }
}